package com.aifeng.view

import android.view.View
import android.widget.ImageView
import com.aifeng.base.loadImage
import com.aifeng.hassan_food.R
import com.aifeng.oss.scaleImage
import com.zhpan.bannerview.BaseBannerAdapter
import com.zhpan.bannerview.BaseViewHolder

class ImageAdapter : BaseBannerAdapter<String, BaseViewHolder<String>>() {

    override fun onBind(
        holder: BaseViewHolder<String>,
        data: String,
        position: Int,
        pageSize: Int
    ) {
        holder.bindData(data, position, pageSize)
    }

    override fun createViewHolder(itemView: View, viewType: Int) =
        object : BaseViewHolder<String>(itemView) {
            override fun bindData(data: String, position: Int, pageSize: Int) {
                val ivImg = findView<ImageView>(R.id.item_banner)
                ivImg.loadImage(
                    url = data.scaleImage(750, 750),
                    resourceId = R.mipmap.default_logo1
                )
            }
        }

    override fun getLayoutId(viewType: Int) = R.layout.item_banner_img

}